<template>
  <figure class="tab-ber-item" @click="itemClick">
    <div v-if="isActive">
      <slot name="item-icon-active"></slot>
    </div>
    <div v-else>
      <slot name="item-icon"></slot>
    </div>
    <div :style="activeStyle">
      <slot name="item-text"></slot>
    </div>
  </figure>
</template>
<script>
export default {
  name: "TabBerItem",
  props: {
    path: String,
    activecolor: {
      type: String,
      default: "red"
    }
  },
  data() {
    return {};
  },
  computed: {
    isActive() {
      return this.$route.path.indexOf(this.path) !== -1;
    },
    activeStyle() {
      return this.isActive ? { color: this.activecolor } : {};
    }
  },
  methods: {
    itemClick() {
      this.$router.push(this.path);
    }
  },
  components: {}
};
</script>
<style lang="less">
.tab-ber-item {
  flex: 1;
  text-align: center;
  height: 49px;
  font: normal normal 14px "微软雅黑";
  img {
    width: 24px;
    height: 24px;
    margin-top: 3px;
    vertical-align: middle;
    margin-bottom: 2px;
  }
}
</style>